<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <style type="text/css">
      body,html,#container{
        height: 100%;
        margin: 0px
      }
     .panel {
        background-color: #ddf;
        color: #333;
        border: 1px solid silver;
        box-shadow: 3px 4px 3px 0px silver;
        position: absolute;
        top: 10px;
        right: 10px;
        border-radius: 5px;
        overflow: hidden;
        line-height: 20px;
      }
      #input{
        width: 250px;
        height: 25px;
        border: 0;
        background-color: white;
      }
    </style>
    <title>上报地理位置</title>
    
  </head>
  <body>
   <div id="container" tabindex="0"></div>
   <div class ='panel'>
      <input id = 'plateNumInput' value = '鄂A12345'></input>
   </div>
   <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=6f44a98bca062cd57301e04f0a92359a"></script>
   <script type="text/javascript" src="resource/script/jquery/1.11.1/jquery.min.js"></script>
   
   <script type="text/javascript">
    
    var map = new AMap.Map('container',{
            resizeEnable: true,
            zoom: 13,
            center: [121.4735623090,31.2303122784]
    });
    
    
    AMap.service('AMap.DistrictSearch', function() {
        var opts = {
            subdistrict: 1,   //返回下一级行政区
            extensions: 'all',  //返回行政区边界坐标组等具体信息
            level: 'city' , //查询行政级别为 市
			zIndex:0
        };
		//实例化DistrictSearch
        district = new AMap.DistrictSearch(opts);
        district.setLevel('district');
        //行政区查询
        district.search('黄浦区', function(status, result) {
            var bounds = result.districtList[0].boundaries;
			points=bounds[0];
            var polygons = [];
            if (bounds) {
                for (var i = 0, l = bounds.length; i < l; i++) {
                    //生成行政区划polygon
                    var polygon = new AMap.Polygon({
                        map: map,
                        strokeWeight: 4,
                        path: bounds[i],
                        fillOpacity: 0,
                        //fillColor: '#FF0000',
                        strokeColor: '#FF0000',
						bubble:true
                    });
                    polygons.push(polygon);
                }
                map.setFitView();//地图自适应
            }
        });
});
    
    
   var marker = new AMap.Marker({
            map:map,
            bubble:true
        })
        map.on('click',function(e){
            marker.setPosition(e.lnglat);
			var longitude=e.lnglat.getLng();
			var latitude=e.lnglat.getLat();
			var plateNum= document.getElementById('plateNumInput').value;
			
            $.post("car_location_create",
           {
              longitude:longitude,
              latitude:latitude,
			  plateNum:plateNum
           },
           function(data,status){
             // alert("Data: " + data + "\nStatus: " + status);
           }
		   );
        })
        
        
        
        
        
   
		

		
   </script>
   <script type="text/javascript" src="http://webapi.amap.com/demos/js/liteToolbar.js"></script>
    
  </body>
</html>